<template>
	<view class="inviteFriends">
		<n-loading></n-loading>
		<!-- 从商家扫码进入需要授权弹窗 -->
		<u-popup v-model="storerShow" mode="bottom" border-radius="16">
			<view class="loginBox">
				<author-login height="88rpx" bgColor="#FF5238" fontColor="#fff" title="微信授权登录" borderRadius="58rpx"></author-login>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default{
		data() {
			return{
				storerShow:false,
				storerOrderId:{
					orderId:null,
					storer:null
				},
				// 小程序码参数
				scene:null,
			}
		},
		onLoad: function (option) {
			var _this = this;
			console.log('商家支付跳过来',option)
			if(option.scene){
				this.scene = this.resolvingScene(option.scene);
				// 小程序码跳进来的参数
				this.storerOrderId.orderId = this.scene.id;
				this.storerOrderId.storer = this.scene.storer;
				if (!uni.getStorageSync('TOKEN')) {
					uni.setStorage({
					    key: 'storerOrder',
					    data: _this.storerOrderId
					});
					_this.storerShow = true;
				}else if(uni.getStorageSync('TOKEN')){
					_this.testToken('/site/get-info',{}).then(res => {
						if(res.data.status==200){//token有效
							uni.reLaunch({
								url: './orderInfoPayment?id='+_this.scene.id
							});
						}else{//token失效
							uni.setStorage({
							    key: 'storerOrder',
							    data: _this.storerOrderId
							});
							_this.storerShow = true;
						}
					})
				}
			}
		}
	}
</script>

<style lang="scss">

	.loginBox{
		padding: 64rpx 32rpx;
	}
</style>
